<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@taglib prefix="sf" uri="http://www.springframework.org/tags/form"%>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>济宁消防车辆人员出入管理系统</title>
<link rel="stylesheet" href="themes/default/easyui.css" />
<link rel="stylesheet" href="themes/icon.css" />
<link rel="stylesheet" href="css/main.css" />
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript" src="jquery.easyui.min.js"></script>
</head>
<body>
	<div id="content">
		<form method="post" id="search_person_form"
			action="record/person/export">
			<table id="search_pc" title="人员出入记录查询">
				<tr>
					<td>&nbsp;时间：<input type="text" class="easyui-datetimebox"
						id="startTime" name="startTime" />~ <input type="text"
						class="easyui-datetimebox" id="endTime" name="endTime" />&nbsp;
						姓名：<input type="text" id="personName" name="personName">&nbsp;机构：<input
						id="orgId" name="orgId" class="easyui-combotree"
						data-options="url:'organization/list',method:'get',valueField:'id',textField:'name',required:true">&nbsp;<a
						href="javascript:searchPersonRecord();" class="easyui-linkbutton"
						data-options="iconCls:'icon-search'">查 询</a>&nbsp; <a
						href="javascript:exportPersonRecord();" class="easyui-linkbutton"
						id="btn_export" data-options="iconCls:'icon-save'">导 出</a>
					</td>
				</tr>
			</table>
		</form>

		<table id="person_rc_dg" title="人员出入记录"
			data-options="fit:false,fitColumns:true,rownumbers:true,idField:'id',pagination:true,url:'record/person/list',method:'get',pageSize:20,onBeforeLoad:beforePersonRecordListLoad">
			<thead>
				<tr>
					<th data-options="field:'id',hidden:true">ID</th>
					<th data-options="field:'name',width:1">姓名</th>
					<th data-options="field:'type',width:1">类型</th>
					<th data-options="field:'warn',width:1,align:'center'">出入情况</th>
					<th data-options="field:'date',width:3,align:'center'">时间</th>
					<th data-options="field:'leave',width:5,align:'left'">申请事由</th>
				</tr>
			</thead>
		</table>

		<script type="text/javascript">
			$(function() {
				var now = new Date();
				now.setDate(new Date().getDate() - 7);
				$('#startTime').datetimebox({
					value : now.Format("yyyy-MM-dd hh:mm:ss"),
					required : true,
					showSeconds : true
				});
				$('#endTime').datetimebox({
					value : new Date().Format("yyyy-MM-dd hh:mm:ss"),
					required : true,
					showSeconds : true
				});
				
				var orgtreeIsOk=false;//机构树加载完成后才能加载数据
				var orgtree = $('#search_person_form #search_pc #orgId').combotree({
					onLoadSuccess:function(node, data){
						orgtree.combotree("setValue",data[0].id);
						orgtreeIsOk=true;
						$('#person_rc_dg').datagrid('load');
					}
				});

				beforePersonRecordListLoad = function(p) {
					if(!orgtreeIsOk){
						return false;//机构树加载完成后才能加载数据
					}
					var orgId = orgtree.combotree("getValue");
					p.orgId=orgId;
					var startTime = $('#startTime').datetimebox('getValue');
					var endTime = $('#endTime').datetimebox('getValue');
					var personName = $('#personName').val();
					p.startTime = startTime;
					p.endTime = endTime;
					p.personName = personName;
				}

				var pager = $('#person_rc_dg').datagrid().datagrid('getPager'); // get the pager of datagrid
				pager.pagination({
					pageSize : 20,
					beforePageText : "第",
					afterPageText : "条",
					displayMsg : "第 {from} 到 {to} 条，共 {total} 条"
				});
			})

			function searchPersonRecord() {
				$('#person_rc_dg').datagrid('reload');
			}

			function exportPersonRecord() {
				var form = $('#search_person_form').form('submit');
			}
		</script>
	</div>
</body>
</html>
